The disclosed embodiments of the present invention relate to forwarding packets, and more particularly, to a parser (e.g., a software-defined parser) for parsing a header in a packet and related packet processing apparatus.
A network switch is a computer networking device that links different electronic devices. For example, the network switch receives an incoming packet generated from a first electronic device connected to it, and transmits a modified packet or an unmodified packet derived from the received packet only to a second electronic device for which the received packet is meant to be received. A parser is a key component of the network switch. Specifically, the parser is responsible for packet header extraction by traversing a protocol tree and extracting header fields interested. The parser result is referenced by following packet processing circuits for packet header classification and action command execution. To achieve better packet processing performance, the parser may be implemented using a fixed hardware circuit. However, such a parser design has no flexibility. Thus, there is a need for an innovative parser design with enhanced flexibility.